package com.leo;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.effect.Blend;
import javafx.scene.effect.BlendMode;
import javafx.scene.effect.Effect;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 * @ClassName BoxBlurDemo
 * @Description
 * @Author wangss
 * @date 2020.07.01 21:15
 * @Version 1.0
 */
public class BlendDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        HBox hBox = new HBox(100);
        Button button = new Button("button");
        ImageView imageView = new ImageView("/images/25.png");
        hBox.getChildren().addAll(button, imageView);

        HBox hBox1 = new HBox(100);
        Button button1 = new Button("button");
        ImageView imageView1 = new ImageView("/images/25.png");
        hBox1.getChildren().addAll(button1, imageView1);
        hBox1.setEffect(createEffect());

        StackPane sp = new StackPane();
        sp.getChildren().addAll(hBox, hBox1);

        AnchorPane an = new AnchorPane();
        an.getChildren().addAll(sp);
        AnchorPane.setTopAnchor(sp, 100d);
        AnchorPane.setLeftAnchor(sp, 100d);

        Scene scene = new Scene(an);
        primaryStage.setScene(scene);
        primaryStage.setHeight(1000d);
        primaryStage.setWidth(1500d);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.show();
    }

    private Effect createEffect() {

        Blend effect = new Blend();
        effect.setOpacity(0.6);
        effect.setMode(BlendMode.ADD);
        return effect;
    }
}
